
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <string>
#include <clocale>
#include <vector>
#include "student.h"

#pragma once
using namespace std;


class studentRegister
{
	vector <student> v;
public:

	studentRegister()
	{
	}

	void add(student b){
		v.push_back(b);
	}

	string list(){
		ostringstream oss;
		string s = "";

		for (int i = 0; i < v.size(); i++){
			oss << i << ".  " << v[i] << endl;
		}
		return oss.str();
	
	}

	void WriteToFile(){

		ofstream fout;
		fout.open("text.txt"); 
		for (int i = 0; i < v.size(); i++)
		{
			fout << v[i] << endl;

		}
		fout.close();

	}

	void ReadFromFile(string in){

		string strRow;
		ifstream fin;
		fin.open(in);
		v.clear();
		while (std::getline(fin, strRow)){
			istringstream iss(strRow);
			student a;
			iss >> a;
			if (a.GetFirstName() != ""){
				v.push_back(a);
			}

		}

		fin.close();

	}

	void ReadFromFile() 

	{
		ReadFromFile("Text2.txt");
	}


	~studentRegister()
	{
	}
};

